/*
 * 单个排行节点对象
 * 用于重写shareNode.js中的shareNode节点对象
 */
let RankNode = function () {
};
RankNode.prototype.getOneNode = function (data) {
    let div = document.createElement("div");
    div.className = "rankPic";
    div.innerHTML =
        '<div class="rankPic-header"><img class="rankPic-img" src="' + data.images[0].thumbUrl + '"></div>\n' +
        '<div class="rankPic-middle"><img class="rankPic-logo" src="' + data.author.userLogo.thumbUrl + '"></div>\n' +
        '<div class="rankPic-bottom">\n' +
        '<div class="rankPic-title">' + data.description + '</div>\n' +
        '<div class="rankPic-like">\n' +
        '<i class="fa fa-heart"></i><span class="num">' + data.totalPraise + '</span>\n' +
        '<i class="fa fa-comments"></i><span class="num">' + data.totalComment + '</span></div>\n' +
        '<div class="rankPic-time">' + data.createTime + '</div>\n' +
        '</div>';
    return div;
};
/**************** rank页中栏分享的自适应**********/
let rankAdjustScreen = function () {
    let nodeArr = [document.querySelectorAll(".rankCont")[0], document.querySelectorAll(".rankCont")[1], document.querySelectorAll(".rankCont")[2], document.querySelectorAll(".rankCont")[3]],
        rankPare = getClass("rank-inner")[0],
        length,
        width;
    if (rankPare.clientWidth > 1100) {
        width = 250;
        length = 4;
    } else if (rankPare.clientWidth > 930) {
        width = 250;
        length = 3;
    } else if (rankPare.clientWidth > 585) {
        width = 250;
        length = 2;
    } else {
        width = (rankPare.clientWidth - 32 - 17) / 2;
        if (width > 250) {
            width = 250;
        }
        length = 2;
    }
    for (let i = 0; i < nodeArr.length; i++) {
        nodeArr[i].style.width = width + "px";
    }
    return length;
};

/*** 以下为主方法 **/
let initRun=function () {
    //左边菜单栏
    FadeModelShowToWindow.init("resize");
    /*导航条的跳转方法*/
    let selectKind = new SelectKind();
    selectKind.setNodeList("rank", ['day', 'week', 'month', 'all'], getClass("line-select")[0]);
    let tem = selectKind.analysisUrl();
    let url = "/rank/" + tem,
        data_send = "userId=" + loginUserId,
        method = "GET",
        nodeName1 = "rank-inner";
    let shareArray = new shareArr();
    shareArray.setPlayNode([document.querySelectorAll(".rankCont")[0], document.querySelectorAll(".rankCont")[1], document.querySelectorAll(".rankCont")[2], document.querySelectorAll(".rankCont")[3]]);
    shareArray.shareNode = new RankNode();
    MainToPage.setBase(data_send, url, method, "Json");
    MainToPage.setNodeListToShow(shareArray, rankAdjustScreen);
    MainToPage.setFirstRequest(false);
    MainToPage.setWindowResize(nodeName1);
};
initRun();
